﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Common
{
    public static class ExpressionGenerator
    {
        public static Func<T, T, T> AdditionExpression<T>()
        {
            ParameterExpression
               parameterA = Expression.Parameter(typeof(T), "a"),
               parameterB = Expression.Parameter(typeof(T), "b");
            BinaryExpression body = Expression.Add(parameterA, parameterB);
            return Expression.Lambda<Func<T, T, T>>(body, parameterA, parameterB).Compile();
        }

        public static Func<T, T, T> MultiplicationExpression<T>()
        {
            ParameterExpression
                parameterA = Expression.Parameter(typeof(T), "a"),
                parameterB = Expression.Parameter(typeof(T), "b");
            BinaryExpression body = Expression.Multiply(parameterA, parameterB);
            return Expression.Lambda<Func<T, T, T>>(body, parameterA, parameterB).Compile();
        }
    }
}
